<h1>客户管理 - <span id="secondHeading">修改客户信息</span></h1>
<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<%= javascript_include_tag "calendar" %>
<script type="text/javascript">
        function checkName(flag){
                if (flag) {
                        if ($("agent_name").value == "")
                        {
                                $("id_name").innerText = "客户名不可为空";
                                $("id_name").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_name").style.display = "none";
                }
        }
        function checkMSN(flag){
                if (flag) {
                        if ($("agent_msn").value != "" && ! checkEmail($("agent_msn").value))
                        {
                                $("id_msn").innerText = "MSN地址不正确";
                                $("id_msn").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_msn").style.display = "none";
                }
        }
        function checkMail(flag){
                if (flag) {
                        if ($("agent_email").value != "" && ! checkEmail($("agent_email").value))
                        {
                                $("id_email").innerText = "邮件地址不正确";
                                $("id_email").style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $("id_email").style.display = "none";
                }
        }
        function checkNum(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! digCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

	function checkForm(){
                return checkName(true) && checkMSN(true) && checkMail(true) && checkNum(true,'id_QQ','agent_qq','QQ号码输入错误');
	}
</script>
<%=form_tag({}, :id => "input-form" ) %>
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<input type="hidden" name="id" value="<%=@agent.id%>">
		<TD>客户名：</TD>
		<TD><input id="agent_name" name="name" type="text" value="<%=@agent.name%>" size="30" maxlength="20" onfocus="checkName(false)" onblur="checkName(true)"/>          <em>*</em><div class="redNsg" id="id_name" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>所属地区：</TD>
		<TD>
			<input name="part" type="text" value="<%=@agent.part%>" size="30" maxlength="20" />
		</TD>
	</TR>
	<TR>
		<TD>联系人：</TD>
		<TD><input name="person" type="text" value="<%=@agent.person%>" size="30" maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>性别：</TD>
		<TD>
		<select name="sex">
        	<option value='0'<%= ' selected' if @agent.sex == 0%>>女</option>
			<option value='1'<%= ' selected' if @agent.sex == 1%>>男</option>
		</select>
		</TD>
        </TR>
        <tr>
        <td>生日：</td>
        <td>
                <script language=javascript>
                        var bir_Date=new dateSelector('<%= @agent.birthday_on %>');
                        bir_Date.inputID='birthday_on';
                        bir_Date.inputName='birthday_on';
                        bir_Date.display();
                </script>
        </td>
        </tr>
	<TR>
		<TD>电话：</TD>
		<TD><input name="phone" type="text" value="<%=@agent.phone%>" size="30" maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>手机：</TD>
		<TD><input name="mobile" type="text" value="<%=@agent.mobile%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>小灵通：</TD>
		<TD><input name="lingtong" type="text" value="<%=@agent.lingtong%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>传真：</TD>
		<TD><input name="fax" type="text" value="<%=@agent.fax%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>地址：</TD>
		<TD><input name="address1" type="text" value="<%=@agent.address1%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>备用地址：</TD>
		<TD><input name="address2" type="text" value="<%=@agent.address2%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>QQ：</TD>
		<TD><input name="qq" id="agent_qq" type="text" value="<%=@agent.qq%>" size="30" maxlength="20" onfocus="checkNum(false,'id_QQ')" onblur="checkNum(true,'id_QQ',this.id,'QQ号码输入错误')")/><div class="redNsg" id="id_QQ" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>MSN：</TD>
		<TD><input name="msn" id="agent_msn" type="text" value="<%=@agent.msn%>" size="30" maxlength="20" onfocus="checkMSN(false)" onblur="checkMSN(true)"/><div class="redNsg" id="id_msn" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>邮件地址：</TD>
		<TD><input name="email" id="agent_email" type="text" value="<%=@agent.email%>" size="30"  maxlength="20" onfocus="checkMail(false)" onblur="checkMail(true)"/><div class="redNsg" id="id_email" style="display:none;"></div></TD>
	</TR>
	<TR>
		<TD>个人爱好：</TD>
		<TD><input name="favor" type="text" value="<%=@agent.favor%>" size="30" maxlength="20" /></TD>
	</TR>
	<TR>
		<TD>备用联系人：</TD>
		<TD><input name="second_person" type="text" value="<%=@agent.second_person%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>备用联系人电话：</TD>
		<TD><input name="second_phone" type="text" value="<%=@agent.second_phone%>" size="30"  maxlength="20"/></TD>
	</TR>
	<TR>
		<TD>备注：</TD>
                <TD><textarea name="memo" type="text" cols="50" rows="5"/><%=@agent.memo%></textarea></TD>
	</TR>
	<TR>
		<TD colspan="2" align="right">
			<input type="submit" value="修改" class="sub" onclick="javascript:return checkForm();">&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></TD>
	</TR>
</TABLE>
 <p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
<%=end_form_tag%>
